is included as a task and loaded with roles/common/handlers/main. the yml file is included as handlers and loaded with roles/common/vars/main. yml is included as a variable. However, when some files exist and some files do not exist, non-existing files will be ignored. The following is the default installation directory of Ansible, which is commonly used by other modules:
When using roles, the behavior of the copy, the template, and the script mod
Ansible @ an efficient configuration management tool-Ansible configure management-translation (10), ansible-ansibleNo written permission. Do not reprint it
Custom ModulesUntil now we have been working solely with the tools provided to us by Ansible.This does afford us a lot of power, and make many things possible. However, if youhave something particularly compl
Ansible @ an efficient configuration management tool-Ansible configure management-translation (4), ansible-ansibleDo not reprint without written permission
Due to the long content in Chapter 3, I will divide it into several parts for translation.
Advanced PlaybooksSo far the playbooks that we have looked at are simple and just run a number ofmodules in order.
Ansible @ an efficient configuration management tool-Ansible configure management-translation (5), ansible-ansibleDo not reprint advanced Playbook without written permission
Extra variablesYou may have seen in our template example in the previous chapter that we used avariable called group_names . This is one of the magic variables that are provided byAnsible it
on the management node:This article installs ansible on the CentOS 6.5 system via Yum and the Epel source is already installed on the machine, please refer to the official documentation for other system installation methods.[Email protected] ~]# yum-y install ansibleCommon configuration items in the ansible configuration file:[defaults]inventory =/etc/
, May 3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]
7.ansible How to get helpAnsible to obtain help information through the Ansible-doc command, you can use the-s option of this command to obtain help for the specified module.Querying the Help documentation for the ping module[[emailprotected] ~]# ansible
] ********************************* *********Changed: [ansibletest]Play recap ************************************** ********************Ansibletest: OK = 2Changed = 1Unreachable = 0Failed = 0
Run the playbook again and the result changes from changed to OK. Congratulations! You have created and executed a module of your own. It is very simple, but you can extend it to get the hostname file, or use other methods to modify the hostname when the system starts.
Writing modules in PythonAll of the
I'm not going to talk about it here, so you can refer to the official documentation. Here I will be divided into three parts to explain: 1, configuration inventory,2, Batch execution command, 3, playbook job.System environment:
Server
IP Address
Operating System
Required Software
Ansible Host
192.168.2.203
Centos 7 64-bit
Ansible learning-ansible
Ansible technologies (Automated O M tools) are developed based on python.
Installation methods include yum, apt, pip, etc.
For example, pip: pip install ansible
The only requirement of ansible for the client is to have SSH and Python (if the python
documentation for the specified moduleUse of the seven Ansible playbookThe equivalent of writing the module to the configuration file,Example 1:VI/ETC/ANSIBLE/TEST.YML//Add the following:---- hosts: lvlinux-2 remote_user: root tasks: - name: test_playbook shell: touch /tmp/lvlinux.txtNote: The first line needs to have three bars, the hosts parameter sp
roles specified by galaxy to the local device; 5 List: List locally downloaded roles; 6 remove: delete locally downloaded roles.2.3 ansible-pull
Ansible uses the push mode by default. The ansible-pull command can be used in another work mode, namely the PULL mode. It is usually applicable to the following scenarios:
A large number of machines need to be configur
, the behavior of the copy, the template, and the script modules isslightly altered. Instead of searching for files by looking from the directory in whichthe playbook file is located, Ansible will look for the files in the location of the role.For example, if you are using a role named common , these modules will change to thefollowing behavior:? The copy module will look for files in roles/common/files .? The template module will look for templates i
, Ansible will look for the files in the location of the role.For example, if you are using a role named common , these modules will change to thefollowing behavior:? The copy module will look for files in roles/common/files .? The template module will look for templates in roles/common/templates .? The script module will look for files in roles/common/files .? Other modules may decide to look for their data in other folders insideroles/common/ . The
Ansible automated O M tool and ansible automated
1 Ansible
1> introduction to ansible
Ansible is a new automatic O M tool developed based on Python. It integrates the advantages of many O M tools (puppet, cfengine, chef, func, fabric, implements batch system configuration
cron-a "Name=empty state=absent"--(delete a scheduled Task)(iii), Ansible scriptAnsible script is similar to the shell script in Linux, in Linux if we need to execute multiple commands to implement a function then we can write these commands into a file to generate a shell script, And the ansible script is to write multiple ansible command grammar modules into a
Sesame HTTP: Ansible extension and sesame ansible ExtensionIntroduction to Ansible
Ansible is an O M tool developed by Python. Because work requires access to Ansible, it often integrates some things into Ansible, so it is more
, ansible order
Ansible is one of the very high usage commands in daily work, which is mainly used in the following scenarios:(1) Non-curing requirements(2) Temporary one-time operation(3) Two times development interface calls
This command is used in the following ways:
Ansible
For example: At work I temporarily want to see if the Web1 server survives, or I wan
Ansible module-lineinfile example, ansible-lineinfileLineinfile module details
The lineinfile module is similar to the sed tool in linux, but the articles on the Internet generally only have simple instances, and there are no examples of complicated points.
The following is a common example of the lineinfile Module I have summarized based on my actual operations.
Directory
If you do not have written authorization, do not reprint it.
Chapter 4 Use of ansible in large projects
New features in 1.3There are two features in Ansible 1.3 that were alluded to previously in the chapter.The first feature is the metadata roles. They allow you to specify that your roledepends on other roles. For example, if the application that you are deploying needsto send mail, your role could depend
Do not reprint advanced playbook without written permission
Finding files with variablesAll modules can take variables as part of their arguments by dereferencing themwith {{ and }} . You can use this to load a particular file based on a variable.For example, you might want to select a different config file for NRPE (a Nagioscheck daemon) based on the architecture in use. Here is how that would look:---#1- name: Configure NRPE for the right architecture#2hosts: ansibletest#3user: root#4tasks:#5
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.